package cn.tedu.car.interceptor拦截器面向切面编程打印执行时间;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
*@author: 吴立涛
*@version 创建时间：2021-2-2717:29:17
*类说明：
*/
@Component //实现HandlerInterceptor接口
public class MyInterceptor实现HandlerInterceptorb接口并写3个拦截器  implements HandlerInterceptor{
	//不用打出来,用alt/快捷键
	@Override  //true代表放行，flase代表拦截，后面的代码都不会放行
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
	System.out.println("我是拦截器 preHandle");
		
	return true; //代表放行
	}
	
	@Override  //业务方法执行之后
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
	
		System.out.println("我是拦截器 postHandler");
		}
	
	@Override  //返回页面之前
     public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
	
		System.out.println("我是拦截器 completion");
	}
	}
